package com.ccsu.eb.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ccsu.eb.mapper.EbProductMapper;
import com.ccsu.eb.model.EbProduct;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description: 用一句话描述
 * @Auther: 新梦想*陈超
 * @Date: 2022/3/18 11:13
 */
@Service
public class EbProductCategoryService {
    @Resource
    private EbProductMapper ebProductMapper;

    public Page findProductListByCateId(Integer cateId,Integer pnum,boolean isBigCate){
        Page page= new Page(pnum,8);
        Page productPage = null;
        if(isBigCate){
            productPage = ebProductMapper.selectPage(page, Wrappers.<EbProduct>lambdaQuery().eq(EbProduct::getEpcId, cateId));
        }else{
            productPage = ebProductMapper.selectPage(page, Wrappers.<EbProduct>lambdaQuery().eq(EbProduct::getEpcChildId, cateId));
        }

        if(productPage==null){
            //TODO 异常 处理
        }
        return  productPage;
    }
}
